'use strict'

// 以流的方式读取文件
//fs.createReadStream();

let fs = require('fs');

let stream1 = fs.createReadStream('./first.html');

//监听data事件,有数据读取出来时就会触发,接受到数据
stream1.on('data',(txt)=>{
    console.log(txt.toString());
})

stream1.on('end',()=>{
    console.log('文件读取完毕');
})

//管道:从一个流将数据流入另外一个流
var s1 = fs.createReadStream('./first.html');
var s2 = fs.createWriteStream('./first2.html');

s1.pipe(s2);